import os
import sys
from functools import reduce
"""
a1:  区间值模糊数 格式为([],[])

self.q: q值
self.x: 一个参数时所用的变量

a2:     区间值模糊数 格式为([],[])

编写时间:2022-6-28 
编写人:吴卓成
参考文献:Exponential operation and aggregation operator for
注意 公式中反r 根据自己属于那一部分区间 (0,1) 与[1,+00] 的采取的转换公式是不一致的  反r 就是权重
"""

from Utilities.AutoGetOperator.selectPackage import get_func


Operator_IVQ_ROFS=get_func(r'Operators/OperationOperators/OperatorIVQROF.py','Operator_IVQ_ROFS')
class WeightedExponentialAggregation(Operator_IVQ_ROFS):
    def getResult(self, *waste1, **waste2):
        data_list=self.data_list 
        weight_list=self.weight_list
        for index ,enum in enumerate(data_list,start=0):#将最初的模糊数 转化为满足WeightedExponentialAggregation的模糊数，公式参照文献
            temp=data_list[index]
            u=[(weight_list[index] ** (1-(enum1**self.q))) ** (1/self.q) for enum1 in temp[0]]
            v=[(1-(weight_list[index]**(enum1**self.q))) ** (1/self.q)  for enum1 in temp[1]]
            data_list[index]=tuple([u,v])
        res=data_list[0]
        data_list=data_list[1::]
        for index ,enum in enumerate(data_list,start=1):
            res=self.multi(res,enum,self.q)#调用原始法则
        return res
if __name__ == '__main__':
    data_list=[([0.31, 0.24], [0.73, 0.72]), ([0.97, 0.12], [0.12, 0.05]),
    ([0.8, 0.52], [0.73, 0.15]), ([0.91, 0.49], [0.42, 0.47]),([0.95, 0.06], [0.19, 0.1])]
    weight_list=[0.1, 0.2, 0.3, 0.1, 0.3],
    Pa = WeightedExponentialAggregation(data_list,weight_list)

    print(Pa.getResult())
   
